﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class feedback_suggest : FBasePage
{
    // Fields

    public string strTitle = "意见反馈";

    // Methods
    private void initPage()
    {
        if (!this.Page.User.Identity.IsAuthenticated)
        {
            base.Response.Redirect("../account/Login.aspx");
        }
        string str = "";
        string name = this.Page.User.Identity.Name;
        Maticsoft.BLL.UserInfo info = new Maticsoft.BLL.UserInfo();
        string strWhere = "";
        strWhere = string.Format(" Username='{0}'", name);
        DataSet list = info.GetList(strWhere);
        if (((list != null) && (list.Tables.Count > 0)) && (list.Tables[0].Rows.Count > 0))
        {
            this.hfUID.Value = list.Tables[0].Rows[0]["id"].ToString();
            this.hfCityID.Value = list.Tables[0].Rows[0]["City_id"].ToString();
            str = list.Tables[0].Rows[0]["Email"].ToString();
        }
        this.feedbackfullname.Value = name;
        this.feedbackemailaddress.Value = str;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (!this.Page.IsPostBack)
        {
            this.initPage();
        }
    }

    private void ShowMsg(string Msg)
    {
        base.Response.Write("<script type=\"text/javascript\">");
        base.Response.Write("alert(\"" + Msg + "\");");
        base.Response.Write("</script>");
    }

    protected void submit_ServerClick(object sender, EventArgs e)
    {
        int num = int.Parse(this.hfUID.Value);
        int num2 = int.Parse(this.hfCityID.Value);
        string str = this.feedbackfullname.Value;
        string str2 = this.feedbackemailaddress.Value;
        string str3 = this.feedbacksuggest.Value;
        if (((str == "") || (str2 == "")) || (str3 == ""))
        {
            this.SetError("请完成信息后再提交!");
            base.Response.Redirect("suggest.aspx");
        }
        if (((((str3.IndexOf("<") != -1) || (str3.IndexOf(">") != -1)) || ((str.IndexOf("<") != -1) || (str.IndexOf(">") != -1))) || (str2.IndexOf("<") != -1)) || (str2.IndexOf(">") != -1))
        {
            this.SetError("不允许输入非法字符，提交失败！");
            base.Response.Redirect("suggest.aspx");
        }
        else
        {
            Maticsoft.BLL.Feedback feedback = new Maticsoft.BLL.Feedback();
            Maticsoft.Model.Feedback model = new Maticsoft.Model.Feedback();
            model.Contact = str2;
            model.Content = str3;
            model.Create_time = DateTime.Now;
            model.title = str;
            model.Category = "suggest";
            model.City_id = num2;
            feedback.Add(model);
            base.Response.Redirect("success.aspx");
        }
    }

}